﻿@model AlumniPlatform.Logic.Model.AlumniInfo

@{
    ViewBag.Title = "Modify";
    Layout = "~/Views/Shared/_Layout.cshtml";
}


<link href="~/Content/admin/assets/bootstrap-datetimepicker/css/datetimepicker.css" rel="stylesheet" />
<script src="~/Content/admin/assets/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script>
<script src="~/bootstrap/dist/js/bootstrapValidator.min.js"></script>
<link href="~/bootstrap/dist/css/bootstrapValidator.min.css" rel="stylesheet" />

<script>
    //打包参数信息
    function packInfo() {
        var data = {
            SerialNumber: '@Model.SerialNumber',
            RealName: $("#RealName").val(),
            Gender: $("#Gender").val(),
            Nation: $("#Nation").val(),
            NativePlace: $("#NativePlace").val(),
            BirthDate: $("#BirthDate").val(),
            MaritalStatus: $("#MaritalStatus").val(),
            Phone: $("#Phone").val(),
            Email: $("#Email").val(),
            MaxDegree: $("#MaxDegree").val(),
            Address: $("#Address").val(),

            Company: $("#Company").val(),
            Position: $("#Position").val(),
            GraduatedFrom: $("#GraduatedFrom").val(),
            Major: $("#Major").val(),
            GraduationDate: $("#GraduationDate").val(),
            AlumniPosition: $("#AlumniPosition").val(),
            Hobby: $("#Hobby").val(),
            Remark: $("#Remark").val(),
        };
        return data;
    }

    function initUi() {
        $('#RealName').val('@Model.RealName');
        $('#Gender').val('@Model.Gender');
        $('#GraduationDate').val('@Model.GraduationDate');
        $("#Phone").val('@Model.Phone');
        $("#Address").val('@Model.Address');

        $("#Nation").val('@Model.Nation'),
        $("#NativePlace").val('@Model.NativePlace'),
        $("#BirthDate").val('@Model.BirthDate'),
        $("#MaritalStatus").val('@Model.MaritalStatus'),
        $("#Email").val('@Model.Email'),
        $("#MaxDegree").val('@Model.MaxDegree'),
        $("#Company").val('@Model.Company');
        $("#Position").val('@Model.Position');
        $("#GraduatedFrom").val('@Model.GraduatedFrom');
        $("#Major").val('@Model.Major');
        $("#AlumniPosition").val('@Model.AlumniPosition');
        $("#Hobby").val('@Model.Hobby');
        $("#Remark").val('@Model.Remark');
    }

    $(function () {
        initUi();//填充数据

        $("#form-test").bootstrapValidator({
            live: 'enable',//验证时机，enabled是内容有变化就验证（默认），disabled和submitted是提交再验证  
            excluded: [':disabled', ':hidden', ':not(:visible)'],//排除无需验证的控件，比如被禁用的或者被隐藏的  
            message: '通用的验证失败消息',//好像从来没出现过  
            feedbackIcons: {//根据验证结果显示的各种图标  
                valid: 'fa fa-check',
                invalid: 'fa fa-times',
                validating: 'fa fa-refresh'
            },
            fields: {
                text: {
                    validators: {
                        notEmpty: {//检测非空,radio也可用  
                            message: '必填项未填写，请输入.'
                        }
                    }
                },
                date: {
                    validators: {
                        date: {//验证指定的日期格式  
                            format: 'YYYY-MM-DD',
                            message: '日期格式不正确'
                        }
                    }
                },
                phone: {
                    validators: {
                        notEmpty: {//检测非空,radio也可用  
                            message: '必填项未填写，请输入.'
                        },
                        regexp: {//正则验证  
                            regexp: /^1[3|4|5|8][0-9]\d{8}$/,
                            message: '所输入的手机号码不符要求'
                        }
                    }
                }
            }
        });


        $('.default-date-picker').datetimepicker({
            format: 'yyyy-mm-dd',
            minView: "month",
            autoclose: true
        });

        $("#submit").click(function () {
            $("#form-test").bootstrapValidator('validate');//提交验证  
            if ($("#form-test").data('bootstrapValidator').isValid()) {//获取验证结果，如果成功，执行下面代码  
                ////验证成功后的操作，如ajax  
                var data = packInfo();
                $.post("Save", data, function (msg) {
                    if (msg.IsSuccess) {
                        console.log("保存成功");
                        Alert("保存成功");
                    }
                    else {
                        console.log("保存失败");
                        Alert("保存失败");
                    }
                })
            }

        })
    })
</script>
<!-- BEGIN WRAPPER -->
<section class="wrapper">
    <!-- BEGIN ROW  -->
    <div class="row">
        <div class="col-md-12 col-lg-12">
            <section class="panel">
                <header class="panel-heading">
                    <span class="label label-primary">基本信息</span>
                    <span class="tools pull-right"></span>
                </header>
                <div class="panel-body ">
                    <form id="form-test" class="form-horizontal tasi-form col-lg-12" method="get">
                        <fieldset disabled>
                            <div class="form-group">
                                <label class="col-sm-2 col-lg-2 control-label">姓名</label>
                                <div class="col-sm-10">
                                    <input name="text" id="RealName" type="text" class="form-control" value="">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 col-lg-2 control-label">性别</label>
                                <div class="col-sm-10">
                                    <select name="choice" id="Gender" class="form-control m-bot15">
                                        <option>男</option>
                                        <option>女</option>
                                    </select>
                                </div>
                            </div>
                        </fieldset>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">毕业时间</label>
                            <div class="col-sm-10">
                                <input name="date" id="GraduationDate" class="form-control form-control-inline input-medium default-date-picker" size="16" type="text" value="">
                                @*<input name="date" id="GraduationDate" type="date" class="form-control">*@
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">手机号码</label>
                            <div class="col-sm-10">
                                <input name="phone" id="Phone" type="text" class="form-control" value="">
                            </div>

                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">联系地址</label>
                            <div class="col-sm-10">
                                <input name="text" id="Address" type="text" class="form-control">
                            </div>
                        </div>

                    </form>


                </div>
            </section>
        </div>

    </div>
    <!-- END ROW  -->

    <!-- BEGIN ROW  -->
    <div class="row">
        <div class="col-md-12 col-lg-12">
            <section class="panel">
                <header class="panel-heading">
                    <span class="label label-primary">其他信息</span>
                    <span class="tools pull-right">
                        <a href="javascript:;" class="fa fa-chevron-down"></a>

                    </span>
                </header>
                <div class="panel-body">
                    <form class="form-horizontal tasi-form" method="get">
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">民族</label>
                            <div class="col-sm-4">
                                <input name="text" id="Nation" type="text" class="form-control">
                            </div>
                            <label class="col-sm-2 col-sm-2 control-label">籍贯</label>
                            <div class="col-sm-4">
                                <input name="text" id="NativePlace" type="text" class="form-control">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">出生日期</label>
                            <div class="col-sm-4">
                                <input id="BirthDate" class="form-control form-control-inline input-medium default-date-picker" size="16" type="text" value="">
                                @*<input name="date" id="BirthDate" type="date" class="form-control">*@
                            </div>
                            <label class="col-sm-2 col-sm-2 control-label">婚否</label>
                            <div class="col-sm-4">
                                <select name="choice" id="MaritalStatus" class="form-control m-bot15">
                                    <option>保密</option>
                                    <option>未婚</option>
                                    <option>已婚</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">电子邮箱</label>
                            <div class="col-sm-4">
                                <input id="Email" type="email" class="form-control" placeholder="jane.doe@example.com">
                            </div>
                            <label class="col-sm-2 col-sm-2 control-label">最高学历</label>
                            <div class="col-sm-4">
                                <select name="choice" id="MaxDegree" class="form-control m-bot15">
                                    <option>本科</option>
                                    <option>大专</option>
                                    <option>研究生</option>
                                    <option>博士</option>
                                </select>
                            </div>

                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">现工作单位</label>
                            <div class="col-sm-4">
                                <input id="Company" type="text" class="form-control">
                            </div>
                            <label class="col-sm-2 col-sm-2 control-label">职务</label>
                            <div class="col-sm-4">
                                <input id="Position" type="text" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">毕业院校</label>
                            <div class="col-sm-4">
                                <input id="GraduatedFrom" type="text" class="form-control">
                            </div>
                            <label class="col-sm-2 col-sm-2 control-label">主修专业</label>
                            <div class="col-sm-4">
                                <input id="Major" type="text" class="form-control">
                            </div>
                        </div>

                        <div class="form-group">

                            <label class="col-sm-2 col-sm-2 control-label">校友会职务</label>
                            <div class="col-sm-4">
                                <select id="AlumniPosition" class="form-control m-bot15">
                                    <option>无</option>
                                    <option>常务理事长</option>
                                    <option>秘书长</option>
                                    <option>理事</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">兴趣爱好</label>
                            <div class="col-sm-10">
                                <input id="Hobby" type="text" class="form-control">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 col-sm-2 control-label">备注</label>
                            <div class="col-sm-10">
                                <textarea id="Remark" class="form-control" rows="3"></textarea>

                            </div>
                        </div>
                    </form>
                </div>
            </section>
        </div>
    </div>
    <!-- END ROW  -->

    <!-- BEGIN ROW -->
    <button type="button" class="btn btn-primary" id="submit">
        保存
    </button>

    <!-- END ROW -->


</section>
<!-- END WRAPPER -->


